package com.game.web.controller.core;

import java.util.List;
import org.springframework.stereotype.Controller;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.game.common.annotation.Log;
import com.game.common.enums.BusinessType;
import com.game.core.domain.PrUserUrl;
import com.game.core.service.IPrUserUrlService;
import com.game.framework.web.base.BaseController;
import com.game.common.page.TableDataInfo;
import com.game.common.base.AjaxResult;
import com.game.common.utils.poi.ExcelUtil;

/**
 * 贫困用户图片 信息操作处理
 * 
 * @author game
 * @date 2020-05-21
 */
@Controller
@RequestMapping("/core/prUserUrl")
public class PrUserUrlController extends BaseController
{
    private String prefix = "core/prUserUrl";
	
	@Autowired
	private IPrUserUrlService prUserUrlService;
	
	@RequiresPermissions("core:prUserUrl:view")
	@GetMapping()
	public String prUserUrl()
	{
	    return prefix + "/prUserUrl";
	}
	
	/**
	 * 查询贫困用户图片列表
	 */
	@RequiresPermissions("core:prUserUrl:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PrUserUrl prUserUrl)
	{
		startPage();
        List<PrUserUrl> list = prUserUrlService.selectPrUserUrlList(prUserUrl);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出贫困用户图片列表
	 */
	@RequiresPermissions("core:prUserUrl:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PrUserUrl prUserUrl)
    {
    	List<PrUserUrl> list = prUserUrlService.selectPrUserUrlList(prUserUrl);
        ExcelUtil<PrUserUrl> util = new ExcelUtil<PrUserUrl>(PrUserUrl.class);
        return util.exportExcel(list, "prUserUrl");
    }
	
	/**
	 * 新增贫困用户图片
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存贫困用户图片
	 */
	@RequiresPermissions("core:prUserUrl:add")
	@Log(title = "贫困用户图片", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PrUserUrl prUserUrl)
	{		
		return toAjax(prUserUrlService.save(prUserUrl));
	}

	/**
	 * 修改贫困用户图片
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		PrUserUrl prUserUrl = prUserUrlService.selectPrUserUrlById(id);
		mmap.put("prUserUrl", prUserUrl);
		return prefix + "/edit";
	}

	/**
	 * 修改保存贫困用户图片
	 */
	@RequiresPermissions("core:prUserUrl:edit")
	@Log(title = "贫困用户图片", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PrUserUrl prUserUrl)
	{		
		return toAjax(prUserUrlService.updateById(prUserUrl));
	}
	
	/**
	 * 删除贫困用户图片
	 */
	@RequiresPermissions("core:prUserUrl:remove")
	@Log(title = "贫困用户图片", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(prUserUrlService.deletePrUserUrlByIds(ids));
	}
	
}
